package com.ruoyi.jeeplus.modules.screen.frontdesk.screen_VideoStream.controller;

import com.ruoyi.jeeplus.modules.screen.frontdesk.screen_VideoStream.mapper.Frontdesk_cameraMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 刘奥旸
 * @version 1.0
 */
@RestController
public class Frontdesk_VideoStreamController {
    @Autowired
    Frontdesk_cameraMapper frontdeskCameraMapper;
    @Autowired
    Frontdesk_VideoStream_utils frontdeskVideoStreamUtils;
    //存在bug，就是有人在后台把地址删了，然后数据库没有同步的话就会出现bug，出现打不开视频的情况
    @GetMapping("/lay/getvideo")
    public String getvideo(@RequestParam String station_id){
//        String station_id = new String("1");
        String finalUrlByStationId = frontdeskCameraMapper.getFinalUrlByStationId(station_id);
        if (finalUrlByStationId.equals("LAYH_null")){
            finalUrlByStationId = frontdeskVideoStreamUtils.getvideo(station_id);
        }

        return finalUrlByStationId;
    }
    //备用地址，一定可以打开视频的
    @GetMapping("/lay/getvideo_LAYH")
    public String getvideo_LAYH(){
        String station_id = new String("1");
        String  finalUrlByStationId = frontdeskVideoStreamUtils.getvideo(station_id);
        return finalUrlByStationId;
    }
}
